/**
 * Created by Administrator on 15-7-1.
 */

var accountList = new AccountList({container:$("#account_list")});
var defaultReply = new DefaultReply({container:$("#defTabPanel")});
var welcomeReply = new WelcomeReply({container:$("#weblTabPanel")});
var Main = RichBase.extend({
	EVENTS : {
		"click" : {
			"#tabNavWrap .tabNav" : "onTabNavClick"
		}
	},
	getHash : function(){ return $("#hashHidInp").val()},
	init : function(opt){
		var hash = this.getHash();
		hash && defaultReply.pullData();
		hash && welcomeReply.pullData();
		accountList.getList();
		accountList.on("ajax_complete",function(res){
			if(!hash){
				hash = res.list[0]["id"];
				$("#hashHidInp").val(hash);
				defaultReply.pullData();
				welcomeReply.pullData();
			}
			$("#account_list").find("option[value='"+hash+"']").attr("selected",true);
		})
	},
	onTabNavClick : function(that,e){
		var tarTab = $(e.currentTarget);
		if(tarTab.hasClass("active")) return false;
		tarTab.addClass("active").siblings().removeClass("active");
		$("#tabConWrap").children(".tabPanel").eq(tarTab.index()).show().siblings().hide();
	}
})

new Main();